﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Project01
{
  
    class MonsterType01:Monster
    {
        //Dữ liệu về Monster01
        public MonsterType01(Game game, int Position)
            : base(game, Position)
        {
                this.ObjectTexture = game.Content.Load<Texture2D>("Images/Monster/Mtype01");
                this.Sprite = new AnimationSprite(ObjectTexture, 1, 4);
                this.Speed = 3;
                this.Sprite.Position = new Vector2(Ran.Next(0, game.Window.ClientBounds.Width-Sprite.RecWidth), (0 - Sprite.RecHeight)*Position);
                this.game = game;
                if (this.Sprite.Position.X >= game.Window.ClientBounds.Width / 2 - 200)
                    MoveState = MonsterMove.Right;
                else if (this.Sprite.Position.X <= game.Window.ClientBounds.Width / 2 - 200)
                    MoveState = MonsterMove.Left;
                else
                    MoveState = MonsterMove.Center;
            
        }
        public override void Update(GameTime gameTime)
        {

            this.Sprite.Update();
            if (MoveState == MonsterMove.Left)
            {
                if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height / 3)
                {
                    this.Sprite.Position.X += Speed * 2;
          
                }
                this.Sprite.Position.Y += Speed;
            }
            else if (MoveState == MonsterMove.Right)
            {
                if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height / 3)
                {
                    this.Sprite.Position.X -= Speed * 2;
                }
                this.Sprite.Position.Y += Speed;
            }
            if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height+Sprite.RecHeight)
                Active = true;


            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch SpriteBatch)
        {

                this.Sprite.Draw(SpriteBatch);
            base.Draw(SpriteBatch);
        }
    }
}
